import { createClient } from 'redis'
import { redisConfig } from 'src/utils/config';
export class redisConnect{
    private client
    constructor(){}
    async getInstance(){
        if(!this.client){
            this.client = await this.connect()
        }
        return this.client
    }
    async connect(){
        const client = await createClient({
            url: `redis://${redisConfig.username}:${redisConfig.password}@${redisConfig.host}:${redisConfig.port}`,
        })
        .on("error", (err) => console.log("Redis Client Error", err))
        .connect();
        return client
    }
    
}